import React from 'react'
import axios from 'axios'

function asyncTable(Com) {
    return (url) => {
        return class NewCom extends React.Component {
            state = {
                list: []
            }
            componentDidMount() {
                axios.get(url).then(res => {
                    console.log(res.data.list)
                    this.setState({
                        list: res.data.list
                    })
                })
            }
            render() {
                const { list } = this.state
                return <div>
                    <Com list = { list }/>
                </div>
            }
        }
    }
}

export {
    asyncTable
}